package com.example.demo.dto;

import java.time.LocalDateTime;

/**
 * AI服务响应DTO
 * 
 * @author Spring AI Demo
 */
public class AiResponse {
    
    /**
     * 生成的内容
     */
    private String content;
    
    /**
     * 请求是否成功
     */
    private boolean success;
    
    /**
     * 错误信息（如果有）
     */
    private String errorMessage;
    
    /**
     * 响应时间戳
     */
    private LocalDateTime timestamp;
    
    /**
     * 使用的模型名称
     */
    private String model;
    
    /**
     * 消耗的Token数量
     */
    private Integer tokensUsed;
    
    /**
     * 处理耗时（毫秒）
     */
    private Long processingTimeMs;

    // 构造函数
    public AiResponse() {
        this.timestamp = LocalDateTime.now();
    }

    public AiResponse(String content) {
        this();
        this.content = content;
        this.success = true;
    }

    public AiResponse(String content, String model) {
        this(content);
        this.model = model;
    }

    // 静态工厂方法
    public static AiResponse success(String content) {
        return new AiResponse(content);
    }

    public static AiResponse success(String content, String model) {
        return new AiResponse(content, model);
    }

    public static AiResponse error(String errorMessage) {
        AiResponse response = new AiResponse();
        response.success = false;
        response.errorMessage = errorMessage;
        return response;
    }

    // Getter和Setter方法
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public LocalDateTime getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public Integer getTokensUsed() {
        return tokensUsed;
    }

    public void setTokensUsed(Integer tokensUsed) {
        this.tokensUsed = tokensUsed;
    }

    public Long getProcessingTimeMs() {
        return processingTimeMs;
    }

    public void setProcessingTimeMs(Long processingTimeMs) {
        this.processingTimeMs = processingTimeMs;
    }

    @Override
    public String toString() {
        return "AiResponse{" +
                "content='" + content + '\'' +
                ", success=" + success +
                ", errorMessage='" + errorMessage + '\'' +
                ", timestamp=" + timestamp +
                ", model='" + model + '\'' +
                ", tokensUsed=" + tokensUsed +
                ", processingTimeMs=" + processingTimeMs +
                '}';
    }
} 